#include <iostream>

using namespace std;

const int N = 1e6 + 10;

int A[N], B[N];
int n, m;

int main(void)
{
    int x;
    cin >> n >> m >> x;
    for (int i = 0; i < n; i++)
        scanf("%d", &A[i]);
    for (int i = 0; i < m; i++)
        scanf("%d", &B[i]);
    int l = 0, r = m - 1;
    while (l < n && r >= 0)
    {
        if (A[l] + B[r] > x)
            r--;
        else if (A[l] + B[r] < x)
            l++;
        else
        {
            cout << l << ' ' << r << endl;
            break;
        }
    }
    return 0;
}